import axios from './axios'
import qs from 'qs'
import { apiUrl, appUrl } from '@/config/config'

// 错题统计 （ 环形图 以及 题目分类总数统计 ）
export const statisticsApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/school/api/classroom/errAnswerRecord',
      method: 'get',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}

// 错题统计 （ 学科 以及 知识点数目统计 ）
export const subjectKnowledgeApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/school/api/classroom/errAnswerRecord/subjectKnowledgeList',
      method: 'get',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}

// 移除错题
export const removeApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/school/api/classroom/errAnswerRecord/errAnswerRecord',
      method: 'put',
      params
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 获取举一反三题目
export const getIdiomApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/school/api/classroom/errAnswerRecord/oneByThree',
      method: 'get',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}

// 提交单题用户答案  （举一反三点提交）
export const singleQuestionApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/school/api/classroom/errAnswerRecord/answerRecord',
      method: 'post',
      data: params
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 答题结果页  （举一反三）
export const resultApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/school/api/classroom/errAnswerRecord/record/' + params,
      method: 'get'
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}

// 单个题目答题解析  （举一反三）
export const singleApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/school/api/classroom/errAnswerRecord/' + params.id,
      method: 'get',
      params: params.data
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}
